using System;
using System.Collections;
using System.Collections.Generic;

namespace SmallStepSemanticCsharp
{

     class Assign: Statement{
         string name;
         Exp exp;
         public Assign (string name,Exp exp){
            this.name = name;
            this.exp = exp;
        
         }
         public override  bool reducible(){
             return true;
         }
         public override MachineState reduce(Dictionary<string,int> env){
            if (exp.reducible()){
                return new MachineState(new Assign(name,exp.reduce(env)), env);
            }else{
                env.Add(name,exp.Val);
                return new MachineState(new DoNothing(), env);
            }

        }
        public override string ToString()
        {
            return String.Format($"{name}={exp}");
        }
    }
}